package com.proton.carepatchtemp.utils.net;

import com.android.volley.Response;
import com.apkfuns.logutils.LogUtils;
import com.proton.carepatchtemp.R;
import com.proton.carepatchtemp.constant.Codes;
import com.proton.carepatchtemp.constant.Extras;
import com.proton.carepatchtemp.utils.eventbus.MainEvent;
import com.proton.carepatchtemp.utils.net.pair.ParamPair;
import com.proton.carepatchtemp.utils.net.pair.ResultPair;
import com.proton.carepatchtemp.utils.net.request.JPost;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Api on 2016/9/25.
 */

public class ConfigCenter extends DataCenter {
    public static final String feedback = "/feedback/add";
    public static final String editConfig = "/user/editconfig";

    public static final boolean feedback(String memo) {
        final int code = Codes.FEEDBACK_ADD;
        if (noNet()) {
            return new MainEvent(code).ret(RET_F).msg(R.string.no_net).post();
        }
        List params = new ArrayList();
        params.add(new ParamPair(Extras.CONTENT, memo));
        VolleyUtil.addRequest(new JPost(getApi(feedback), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                if (response.isSuccess()) {
                    LogUtils.e("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Success");
                }
                new MainEvent(code).ret(ret).msg(msg).post();
            }
        }, code));
        return false;
    }
}
